package cn.edu.nju.gitlab.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.edu.nju.gitlab.R;
import cn.edu.nju.gitlab.model.User;
import cn.edu.nju.gitlab.Image;

/**
 * Created by lpt on 2017/6/7.
 */

public class UserInfoFragment extends BaseFragment {
//    @BindView(R.id.avatar)
//    ImageView avatar;
    @BindView(R.id.username)
    TextView username;
    @BindView(R.id.exam_title)
    TextView name;
    @BindView(R.id.gender)
    TextView gender;
    @BindView(R.id.email)
    TextView email;
    @BindView(R.id.gitId)
    TextView gitId;
    @BindView(R.id.number)
    TextView number;
    private User user;

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.user_info, container, false);
        ButterKnife.bind(this, view);
    //    new Image(avatar).execute(user.getAvatar());
        username.setText(""+user.getUsername());
        name.setText( ""+user.getName());
        gender.setText(""+user.getGender());
        email.setText(""+user.getEmail());
        if (user.getType().equals("student")) {
            gitId.setText(""+
                    user.getGitId());
            number.setText(""+user.getNumber());
        }
        return view;
    }
}
